package com.binarytree;

public class Solution10 {
    public int minDepth(TreeNode root) {
        if (root == null) return 0;
        int l = minDepth(root.left);
        int r = minDepth(root.right);
        if (root.left == null) return r + 1;
        if (root.right == null) return l + 1;
        return Math.min(l, r) + 1;
    }
}
